/*
 * Improbability Drive
 * Phillip Cardon, Thach Nguyen, Cristopher Claeys
 * 4/26/2011
 */

package testers;

import java.net.URL;

import buffers.SynchronizedBuffer;

public class RemoveUrls extends Thread {
	SynchronizedBuffer<URL> pb;
	public RemoveUrls (SynchronizedBuffer<URL> buffer) {
		pb = buffer;
	}
	
	public void run() {
		boolean sleeping = false;
		while(true) {
			synchronized (pb) {
				if (pb.size() > 0) {
					URL u = pb.dequeue();
					System.out.println("Removed: " + u.toString());
					sleeping = false;
				} else {
					sleeping = true;
				}
			}
			if (sleeping) {
				try {
					sleep(1);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
}
